package com.batch_demo.jdk8;

import java.util.Arrays;

public class Lambda {
    public void m1() {
        Arrays.asList("a", "b", "c", "d").forEach(e -> System.out.println(e));
    }

    public void m2() {
        Arrays.asList("a", "b", "c", "d").forEach((String e) -> System.out.println(e));
    }

    public void m3() {
        Arrays.asList("a", "b", "d").forEach(e -> {
            System.out.println(e);
            System.out.println(e);
        });
    }

    public void m4() {
        String separator = ",";
        Arrays.asList("a", "b", "d").forEach((String e) -> System.out.println(e + separator));
    }

    public void m5() {
        final String separator = ",";
        Arrays.asList("a", "b", "d").forEach((String e) -> System.out.println(e + separator));
    }

    public void m6() {
        Arrays.asList("a", "b", "d").sort((e1, e2) -> e1.compareTo(e2));

        Arrays.asList("a", "b", "d").sort((e1, e2) -> {
            int result = e1.compareTo(e2);
            return result;
        });
    }
}
